# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Stefan Kirrmann <stefan.kirrmann at gmail dot com>

pkgname=open-iscsi
pkgver=2.1.9
pkgrel=2
pkgdesc='iSCSI userland tools'
arch=('loong64' 'x86_64')
url='https://www.open-iscsi.com/'
license=('GPL')
makedepends=('meson' 'systemd')
depends=('systemd-libs' 'util-linux-libs' 'kmod' 'openssl' 'open-isns')
install=$pkgname.install
backup=('etc/iscsi/iscsid.conf'
	'etc/iscsi/initiatorname.iscsi')
options=('docs')
source=("$pkgname-$pkgver.tar.gz::https://github.com/open-iscsi/open-iscsi/archive/$pkgver.tar.gz")
sha256sums=('60e2a1e3058a8af7f702e86a5a0511b05b8754d29d3d2df4e0e301399b5cf70a')

build() {
  local _meson_options=(
    -Discsi_sbindir=/usr/bin/
    -Drulesdir=/usr/lib/udev/rules.d/
  )

  arch-meson "${pkgname}-${pkgver}" build "${_meson_options[@]}"
#  arch-meson -D rulesdir="/usr/lib/udev/rules.d build" -Discsi_sbindir=/usr/bin build
  meson compile -C build
}

package() {
  DESTDIR="${pkgdir}" meson install -C build

  # no initiatorname in package, initialized in install script
  echo -n > "${pkgdir}"/etc/iscsi/initiatorname.iscsi
#  meson install -C build --destdir "$pkgdir"

  # install docs
  install -D -m0644 -t "${pkgdir}"/usr/share/doc/${pkgname}/ "${pkgname}-${pkgver}"/{Changelog,README}
}
